import request from '@/utils/request';

/**
 * 获取项目
 */
export function getProfile(params) {
  return request({
    url: 'api/project/',
    method: 'get',
    params,
  });
}

/**
 * 新增项目
 */
export function add(data) {
  return request({
    url: 'api/project/',
    method: 'post',
    data,
  });
}

/**
 * 编辑项目
 */
export function edit(data) {
  return request({
    url: 'api/project/',
    method: 'put',
    data,
  });
}

/**
 * 删除项目
 */
export function del(data) {
  return request({
    url: 'api/project/',
    method: 'delete',
    data,
  });
}

/**
 * 获取项目列表
 */
export function getAll(params) {
  return request({
    url: 'api/project/all',
    method: 'get',
    params,
  });
}

/**
 * 项目状态改变记录
 */
export function getProjectStatus(params) {
  return request({
    url: '/api/project/status/all',
    method: 'get',
    params,
  });
}

/**
 * 项目开标,开标之后就都不能再报价了
 */
export function openProjectBid(data) {
  return request({
    url: '/api/project/status/open',
    method: 'post',
    data,
  });
}

/**
 * 项目授标
 */
export function setProjectAward(data) {
  return request({
    url: '/api/project/status/award',
    method: 'post',
    data,
  });
}

/**
 * 二次报价
 */
export function setOfferAgent(data) {
  return request({
    url: 'api/project/status/twice',
    method: 'post',
    data,
  });
}

/**
 * 供应商查看项目信息
 */
export function getSupplierProject(params) {
  return request({
    url: 'api/project_supplier/project',
    method: 'get',
    params,
  });
}

/**
 * 增加供应商
 */
export function addSupplier(data) {
  return request({
    url: 'api/project_supplier/invite',
    method: 'post',
    data,
  });
}

/**
 * 删除供应商
 */
export function delSupplier(data) {
  return request({
    url: 'api/project_supplier/uninvite',
    method: 'post',
    data,
  });
}

/**
 * 获取项目的供应商列表
 */
export function getSupplier(params) {
  return request({
    url: '/api/project_supplier/supplier/all',
    method: 'get',
    params,
  });
}

/**
 * 报名
 */
export function applyProject(data) {
  return request({
    url: '/api/project_supplier/apply',
    method: 'post',
    data,
  });
}

/**
 * 报名通过
 */
export function applyPass(data) {
  return request({
    url: '/api/project_supplier/audit',
    method: 'post',
    data: {
      ...data,
      status: 'PASS',
    },
  });
}

/**
 * 报名通过
 */
export function applyProjectPass(data) {
  return request({
    url: '/api/project_supplier/update',
    method: 'post',
    data: {
      ...data,
      status: 'PASS',
    },
  });
}

/**
 * 报名不通过
 */
export function applyProjectBlock(data) {
  return request({
    url: '/api/project_supplier/update',
    method: 'post',
    data: {
      ...data,
      status: 'BLOCK',
    },
  });
}

/**
 * 报价
 */
export function offerPrice(data) {
  return request({
    url: '/api/project_supplier/price',
    method: 'post',
    data,
  });
}
